package com.khong.sale.ui;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.khong.sale.R;
import com.khong.sale.entity.ContactsInfo;
import com.khong.sale.ui.ContactsListItems.Holder;

public class ContactsContentItem implements ContactsListItems {
	private ContactsInfo cinfo;

	public ContactsInfo getCinfo() {
		return cinfo;
	}

	public void setCinfo(ContactsInfo cinfo) {
		this.cinfo = cinfo;
	}

	private int type;

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public ContactsContentItem(ContactsInfo cinfo, int type) {
		this.type = type;
		this.cinfo = cinfo;
	}

	@Override
	public int getLayout() {
		return R.layout.contacts_list_item;
	}

	@Override
	public boolean isClickable() {
		return true;
	}

	@Override
	public View getView(Context context, View view, LayoutInflater inflater) {
		Holder hoder;
		if (view == null) {
			hoder = new Holder();
			view = inflater.inflate(getLayout(), null);
			hoder.txt1 = (TextView) view.findViewById(R.id.user_name);
			hoder.txt2 = (TextView) view.findViewById(R.id.user_num);
			view.setTag(hoder);
		} else {
			hoder = (Holder) view.getTag();
		}
		hoder.txt1.setText(cinfo.getName());
		hoder.txt2.setText(cinfo.getPhone());
		return view;
	}

}
